<template>
  <div id="" class="headerTab">
    <span v-for="(item,index) in headerArr" :key="item.key"
    @click="setActive(index)"
    :class="{active:idx==index}">{{item}}</span>
  </div>
</template>
<script>
import Vue from 'vue'
export default {
  name: "",
  props: ['headerArr','findType'],
  data: () => ({
    idx:0,
  }),
  methods: {
    setActive(index) {
      this.idx = index;
      this.$emit('tabEvent',index);
    }
  },
  watch: {
    findType(newValue, oldValue) {
        console.log(newValue);
        let str = '';
        switch (newValue) {
          case 0:
            str = '找陪练';
            break;
          case 1:
            str = '找圈友';
            break;
          case 2:
            str = '找教练';
            break;
          default:

        }
        Vue.set(this.headerArr,0,str);
    }
  },
  mounted() {
    //do something after mounting vue instance
    console.log(this.findType);

  }
}
</script>
<style lang="scss" scoped>
.headerTab{
  position: fixed;
  top: 0;
  left: 10%;
  right: 12%;
  height: 40px;
  line-height: 40px;
  text-align: center;
  z-index: 999;
  span{
    color: $lightBlue;
    display: inline-block;
    width: 100px;
    text-align: center;
    font-size: 16px;
    &.active{
      color: white;
    }
  }
}
</style>
